﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Snake.Cache
{
   public class CacheKey
    {
        public static String getObject(Type t, object id)
        {
            return getObject(t.FullName, id);
        }

        public static String getObject(String typeFullName, object id)
        {
            return "__object_" + typeFullName + "_" + id;
        }

        public static String getObjectAll(Type t)
        {
            return "__objectAll_" + t.FullName + "_all";
        }

        public static String getQuery(Type t, String sql, Dictionary<String, Object> parameters)
        {
            String str = sql + " paramValue : ";
            foreach (KeyValuePair<String, Object> pair in parameters)
            {
                str = str + " \"" + (pair.Value) + "\", ";
            }

            return "__objectQueryList_" + t.FullName + "_" + str.Trim().TrimEnd(',');
        }

        public static string getCountKey(Type t)
        {
            return "__objectCount_" + t.FullName;
        }

        public static string getCountKey(Type t, string condition)
        {
            return "__objectCount_" + t.FullName + "_" + condition;
        }

        public static String getSqlKey(String sql)
        {
            return "__objectSql_" + sql;
        }
    }
}
